package com.medicine.service.impl;

import org.springframework.stereotype.Service;

import com.medicine.dao.impl.TeacherDao;

import pagination.Page;
import po.Gys;
import po.Teacher;
import requestvo.GysReqVo;
import requestvo.TeacherReqVo;

@Service
public class TeacherService extends BaseServiceImpl {

	public String hasTeacher(String userId, String password) {
		// TODO 自动生成的方法存根
		if (userId != null && password != null) {
			try {
				Teacher teacher = teacherDao.get(userId);
				if (teacher.getTech_psw().equals(password)) {
					String username = teacher.getTech_name();
					return username;
				}
			} catch (Exception e) {
				e.printStackTrace();
				// TODO: handle exception
			}
		}
		return null;
	}

	public String ifHasTeacher(String userId) {
		// TODO 自动生成的方法存根
		if (userId != null) {
			try {
				Teacher teacher = teacherDao.get(userId);
				String username = teacher.getTech_name();
				return username;
			} catch (Exception e) {
				e.printStackTrace();
				// TODO: handle exception
			}
		}
		return null;
	}

	public Page findtechxx(TeacherReqVo teacherReqVo) {
		Page<TeacherReqVo> page = new Page<>();
		if (teacherReqVo.getTech_no() != null
				&& !teacherReqVo.getTech_no().equals("")) {
			page.getParams().put("tech_no", teacherReqVo.getTech_no());
		}
		if (teacherReqVo.getTech_name() != null
				&& !teacherReqVo.getTech_no().equals("")) {
			page.getParams().put("tech_name",
					"%" + teacherReqVo.getTech_name() + "%");
		}
		if (teacherReqVo.getTech_psw() != null
				&& !teacherReqVo.getTech_psw().equals("")) {
			page.getParams().put("tech_psw", teacherReqVo.getTech_psw());
		}
		if (teacherReqVo.getTech_tel() != null
				&& !teacherReqVo.getTech_tel().equals("")) {
			page.getParams().put("tech_tel",
					"%" + teacherReqVo.getTech_tel() + "%");
		}
		/*
		 * if(teacherReqVo.getTech_name()!=null&&
		 * !teacherReqVo.getTech_no().equals("")){
		 * page.getParams().put("gysfzr", "%"+teacherReqVo.getTech_name()+"%");
		 * }
		 */
		page.setPageNo(teacherReqVo.getPage());
		page.setPageSize(teacherReqVo.getRows());
		page.setResults(teacherDao.findPage(page));
		return page;
	}

	public void updatetechxx(TeacherReqVo teacherReqVo) {
		// TODO Auto-generated method stub
		teacherDao.update(teacherReqVo);

	}

	public void addtechxx(TeacherReqVo teacherReqVo) {
		// TODO Auto-generated method stub
		teacherDao.insert(teacherReqVo);
	}

	public void deltechxx(String[] integers) {
		// TODO Auto-generated method stub
		teacherDao.delete(integers);
	}

}
